package com.yanqu.road.server.timer.bulletscreen;

import com.yanqu.road.server.manger.activity.bulletscreen.ActivityBulletScreenMgr;
import com.yanqu.road.utils.LocalDateTimeHelper;
import com.yanqu.road.utils.executor.GeneralTask;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class BulletScreenTask extends GeneralTask {

    protected Logger logger = LogManager.getLogger(BulletScreenTask.class.getName());

    private long lastUpdateTime = 0L;

    @Override
    public void doRun() {
        //启动执行一次
        try {
            long zeroTimeStamp = LocalDateTimeHelper.getZeroTimeTimeStamp();
            if (lastUpdateTime < zeroTimeStamp) {
                //清理过期数据
                ActivityBulletScreenMgr.removeOutTimeMsg();
                lastUpdateTime = zeroTimeStamp;
            }
        }catch (Exception e) {
            logger.error(e.getMessage(), e);
        }

        ActivityBulletScreenMgr.syncBarrageMessageToClient();
    }
}
